package com.woniuxy.movie.commons.web.exception;

import com.woniuxy.movie.commons.core.exception.MovieException;
import com.woniuxy.movie.commons.core.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class MovieExceptionExcutor {

    @ExceptionHandler(Throwable.class)
    public Result<String> excutorThrowble(Throwable e){
        log.error("出现异常",e);
        return Result.getResult(String.class).setCode(500).setMsg("系统错误");
    }

    @ExceptionHandler(MovieException.class)
    public Result<String> excutorMovieException(MovieException e){
        log.error("出现异常",e);
        return Result.getResult(String.class).setCode(e.getCode()).setMsg(e.getMessage());
    }

}
